package com.dunshanasync.controller;

import com.dunshanasync.mapper.PageInstanceMapper;
import com.dunshanasync.pojo.PageInstance;
import com.dunshanasync.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * @author liwen406
 * @program: dunshan-pef
 * @description: page文件
 * @date 2021-08-09 09:52:33
 */
@Controller
public class PageInstanceController {
    @Autowired
    PageInstanceMapper pageInstanceMapper;


    @Autowired
    UserInfoService userInfoService;


    @GetMapping("/page")
    @ResponseBody
    public Object pageIns() {

        
        HashMap<String, Object> map = new HashMap<>();
        map.put("page_id", "");
        List<PageInstance> pageInstances = pageInstanceMapper.selectByMap(null);
        map.put("ok", pageInstances);
        return map;
    }


    @GetMapping("/insert")
    @ResponseBody
    public Object pageInsInsert() {
        HashMap<String, Object> map = new HashMap<>();
        for (int i = 0; i < 10000; i++) {
            PageInstance pageInstance = new PageInstance();
            pageInstance.setPageId(i + 2L);
            pageInstance.setSite(i);
            pageInstance.setVenderId(100L);
            pageInstance.setShopId(100L);
            pageInstance.setChannelType(1);
            pageInstance.setPlatform(1);
            pageInstance.setThemeId(1L);
            pageInstance.setYn(1);
            pageInstance.setCreateTime(new Date());
            pageInstance.setModifyTime(new Date());
            pageInstanceMapper.insert(pageInstance);
        }

        return map;
    }
    @GetMapping("/inserts")
    @ResponseBody
    public Object pageInsInserts() {
        HashMap<String, Object> map = new HashMap<>();
        userInfoService.saveAll();
        return map;
    }


}
